Array.prototype.myFilter = function (callback, thisArg) {
  if(typeof this === "undefined") {
    throw new TypeError("this is undefined")
  }
  if(typeof callback !== "function") {
    throw new TypeError(callback + "mast is function")
  }

  let result = [];
  let len = this.length;

  for(let i=0;i<len;i++){
    if(callback.call(thisArg, this[i], i, this)) {
      result.push(this[i])
    }
  }

  return result;
}

const arr = [1,2,3,4,5,6]
console.log(arr.myFilter((item, index) => {
  return item > 3;
}))